package com.wwy.service;

import com.alibaba.fastjson.JSONObject;
import com.wwy.LabelDialog;
import com.wwy.Utils;
import com.wwy.domain.LabelEntity;
import com.wwy.domain.TypeEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.File;

import java.util.List;

/**
 * @Author: wwy
 * @Date: 2020/8/13 15:23
 */
@Service
public class LableSaveService {
    @Value("${filePath}")
    private String filePath;
    /**
     * 保存label标签
     * @param labelEntityList
     */
    public void labelSave(List<LabelEntity> labelEntityList){
        //保存
        File file = new File(filePath);
        if(!file.exists()){
            file.mkdirs();
        }
        String filePathName = filePath+"label.xy";
        String labelEntityJson = JSONObject.toJSONString(labelEntityList);
        Utils.saveData(filePathName,labelEntityJson);
    }

    /**
     * 保存type
     * @param typeEntityList
     */
    public void typeSave(List<TypeEntity> typeEntityList){
        //保存
        File file = new File(filePath);
        if(!file.exists()){
            file.mkdirs();
        }
        String filePathName = filePath+"labelType.xy";
        String labelEntityJson = JSONObject.toJSONString(typeEntityList);
        Utils.saveData(filePathName,labelEntityJson);
    }
}
